package xin.marcher.module.diplomacy.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xin.marcher.module.common.core.JsonResult;
import xin.marcher.module.diplomacy.api.*;
import xin.marcher.module.diplomacy.domain.dto.*;
import xin.marcher.module.diplomacy.domain.query.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 *
 */
@RestController
@RequestMapping("/forJmeter")
public class ForJmeterController {

    @Resource
    private FrontCategoryApi frontCategoryApi;

    @Resource
    private ProductCollectApi productCollectApi;

    @Resource
    private ProductLabelApi productLabelApi;

    @Resource
    private ProductSaleApi productSaleApi;

    @Resource
    private ProductSearchApi productSearchApi;

    @PostMapping("/getFrontCategory")
    public JsonResult<List<FrontCategoryDTO>> getFrontCategory(@RequestBody FrontCategoryQuery frontCategoryQuery) {
        return frontCategoryApi.getFrontCategory(frontCategoryQuery);
    }

    @PostMapping("/getFrontCategorySkuList")
    public JsonResult<FrontCategorySkuRelationDTO> getFrontCategorySkuList(@RequestBody FrontCategoryQuery frontCategoryQuery) {
        return frontCategoryApi.getFrontCategorySkuList(frontCategoryQuery);
    }

    @PostMapping("/getProductCollect")
    public JsonResult<Map<String, ProductCollectDTO>> getProductCollect(@RequestBody ProductCollectQuery productCollectQuery) {
        return productCollectApi.getProductCollect(productCollectQuery);
    }

    @PostMapping("/getProductDetail")
    public JsonResult<ProductDetailDTO> getProductDetail(@RequestBody ProductDetailQuery productDetailQuery) {
        return productCollectApi.getProductDetail(productDetailQuery);
    }

    @PostMapping("/listLabels")
    public JsonResult<List<LabelDTO>> listLabels(@RequestBody FrontCategoryLabelQuery request) {
        return productLabelApi.listLabels(request);
    }

    @PostMapping("/listProducts")
    public JsonResult<List<ProductLabelRelationDetailDTO>> listProducts(@RequestBody LabelProductQuery request) {
        return productLabelApi.listProducts(request);
    }

    @PostMapping("/getSaleSkuByPage")
    public JsonResult<ProductSaleCollectDTO> getSaleSkuByPage(@RequestBody ProductSaleQuery productSaleQuery) {
        return productSaleApi.getSaleSkuByPage(productSaleQuery);
    }

    @PostMapping("/getSaleSkuBySellerId")
    public JsonResult<List<String>> getSaleSkuBySellerId(Long sellerId) {
        return productSaleApi.getSaleSkuBySellerId(sellerId);
    }

    @PostMapping("/checkSaleSku")
    public JsonResult<ProductSaleRelationDTO> checkSaleSku(@RequestBody ProductSaleRelationQuery productSaleRelationQuery) {
        return productSaleApi.checkSaleSku(productSaleRelationQuery);
    }

    @PostMapping("/searchProducts")
    public JsonResult<PorductSearchDTO> searchProducts(@RequestBody ProductSearchQuery request) {
        return productSearchApi.searchProducts(request);
    }
}
